//
//  QDFocusCell.m
//  QuickDoctor
//
//  Created by ycw on 2016/12/22.
//  Copyright © 2016年 Eric. All rights reserved.
//

#import "QDFocusCell.h"
#import "QDFocusModel.h"
#import "QDDoctorMassegeController.h"

@interface QDFocusCell()

@end

@implementation QDFocusCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpUI];
    }
    
    return self;
    
}

#pragma mark
#pragma mark - 设置cell
- (void) setUpUI
{
    
    UIView *backView = [[UIView alloc] init];
    
    backView.backgroundColor = [UIColor colorWithRed:241/255.0 green:242/255.0 blue:242/255.0 alpha:1];
    
    [self.contentView addSubview:backView];
    
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.leading.trailing.equalTo(self.contentView);
        
        make.height.equalTo(@20);
    }];
    
    UIImageView *imageRight = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pipeidu"]];
    
    [backView addSubview:imageRight];
    
    [imageRight mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(backView).mas_offset(15);
        
        make.trailing.equalTo(backView).mas_offset(-30);
        
        make.height.mas_equalTo(60);
        
        make.width.mas_equalTo(40);
        
    }];
    
    UILabel *lblImage = [[UILabel alloc] init];
    
    lblImage.text = @"匹配度92%";
    
    lblImage.numberOfLines = 2;
    
    lblImage.font = [UIFont systemFontOfSize:10];
    
    lblImage.textColor = [UIColor whiteColor];
    
    lblImage.textAlignment = NSTextAlignmentCenter;
    
    [imageRight addSubview:lblImage];
    
    [lblImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imageRight).mas_offset(5);
        
        make.height.mas_equalTo(40);
        
        make.leading.equalTo(imageRight).mas_offset(5);
        
        make.trailing.equalTo(imageRight).mas_offset(-2);
        
    }];
    
    UIImageView *imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"illness_img_person.png"]];
    
    imgV.layer.masksToBounds = YES;
    
    imgV.layer.cornerRadius = 45;
    
    [self.contentView addSubview:imgV];
    
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.contentView).mas_offset(-140);
        
        //make.centerY.equalTo(self.contentView);
        
        make.top.equalTo(self.contentView).mas_offset(30);
        
        make.bottom.equalTo(self.contentView).mas_offset(-10);
        
        make.width.mas_equalTo(90);
        
        make.height.mas_equalTo(90);
        
    }];
    
    UILabel *lblName = [[UILabel alloc] init];
    
    lblName.font = [UIFont systemFontOfSize:18];
    
    [self.contentView addSubview:lblName];
    
    self.lblName = lblName;
    
    [lblName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imgV);
        
        make.leading.equalTo(imgV.mas_trailing).mas_offset(10);
        
        make.width.equalTo(@70);
        
    }];
    
    UILabel *lblTitle = [[UILabel alloc] init];
    
    lblTitle.font = [UIFont systemFontOfSize:15];
    
    lblTitle.textColor = [UIColor lightGrayColor];
    
    [self.contentView addSubview:lblTitle];
    
    self.lblTitle = lblTitle;
    
    [lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(imgV);
        
        make.leading.equalTo(lblName.mas_trailing).mas_offset(5);
        
        make.trailing.equalTo(self.contentView).mas_offset(-10);
        
    }];
    
    UILabel *lblText = [[UILabel alloc] init];
    
    lblText.font = [UIFont systemFontOfSize:15];
    
    lblText.textColor = [UIColor lightGrayColor];
    
    [self.contentView addSubview:lblText];
    
    self.lblText = lblText;
    
    [lblText mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lblName.mas_bottom).mas_offset(5);
        
        make.leading.equalTo(imgV.mas_trailing).mas_offset(8);
        
        make.trailing.equalTo(self.contentView).mas_offset(-10);
        
    }];
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn1 setImage:[UIImage imageNamed:@"yuyueliang"] forState:UIControlStateNormal];
    
    [btn1 setTitle:@"35" forState:UIControlStateNormal];
    
    btn1.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [btn1 setTitleColor:[UIColor colorWithRed:57/255.0 green:197/255.0 blue:196/255.0 alpha:1] forState:UIControlStateNormal];
    
    [btn1 setTitleEdgeInsets:UIEdgeInsetsMake(15, -btn1.imageView.bounds.size.width + 10, 15, 0)];
    [btn1 setImageEdgeInsets:UIEdgeInsetsMake(10, 5, 10, 0)];
    
    [self.contentView addSubview:btn1];
    
    [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(lblName);
        
        make.top.equalTo(lblText.mas_bottom).mas_offset(5);
        
        make.height.mas_equalTo(40);
        
        make.width.mas_equalTo(40);
        
    }];
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn2 setImage:[UIImage imageNamed:@"xianhua"] forState:UIControlStateNormal];
    
    [btn2 setTitle:@"194" forState:UIControlStateNormal];
    
    btn2.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [btn2 setTitleColor:[UIColor colorWithRed:57/255.0 green:197/255.0 blue:196/255.0 alpha:1] forState:UIControlStateNormal];
    
    [btn2 setTitleEdgeInsets:UIEdgeInsetsMake(15, -btn2.imageView.bounds.size.width + 10, 15, 0)];
    [btn2 setImageEdgeInsets:UIEdgeInsetsMake(10, 5, 10, 0)];
    
    [self.contentView addSubview:btn2];
    
    [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(btn1.mas_trailing).mas_offset(5);
        
        make.top.equalTo(lblText.mas_bottom).mas_offset(5);
        
        make.height.mas_equalTo(40);
        
        make.width.mas_equalTo(50);
        
    }];
    
    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn3 setImage:[UIImage imageNamed:@"jinqi"] forState:UIControlStateNormal];
    
    [btn3 setTitle:@"100" forState:UIControlStateNormal];
    
    btn3.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [btn3 setTitleColor:[UIColor colorWithRed:57/255.0 green:197/255.0 blue:196/255.0 alpha:1] forState:UIControlStateNormal];
    
    [btn3 setTitleEdgeInsets:UIEdgeInsetsMake(15, -btn3.imageView.bounds.size.width + 10, 15, 0)];
    [btn3 setImageEdgeInsets:UIEdgeInsetsMake(10, 5, 10, 0)];
    
    [self.contentView addSubview:btn3];
    
    [btn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(btn2.mas_trailing).mas_offset(5);
        
        make.top.equalTo(lblText.mas_bottom).mas_offset(5);
        
        make.height.mas_equalTo(40);
        
        make.width.mas_equalTo(50);
        
    }];
    
}

#pragma mark
#pragma mark - 重写setModel方法
- (void)setModelList:(QDFocusModel *)modelList
{
    
    _modelList = modelList;
    
    self.lblName.text = modelList.doctor_name;
    
    self.lblTitle.text = modelList.doctor_title_name;
    
    self.lblText.text = modelList.hospital_name;

    
}





@end
